Skip to content

Fix: Prevent Tiled Gallery crash and add changelog entry (#49606)#50025

Merged
jeherve merged 3 commits into
Automattic:trunkfrom
Tejas-Raj01:fix/tiled-gallery-crash
Jul 3, 2026
Merged

Fix: Prevent Tiled Gallery crash and add changelog entry (#49606)#50025
jeherve merged 3 commits into
Automattic:trunkfrom
Tejas-Raj01:fix/tiled-gallery-crash

Conversation

@Tejas-Raj01

Copy link
Copy Markdown
Contributor

Fixes #49606

Proposed changes

  • Fixes an editor crash that occurs when transforming a Gallery block back to a Tiled Gallery. The fix ensures the images attribute is recovered from innerBlocks when the top-level images attribute is empty or undefined.

Related product discussion/links

Does this pull request change what data or activity we track or use?

  • No, this PR does not change any data tracking or activity collection.

Testing instructions

  • Go to any Post or Page in the Block Editor.
  • Add a standard "Gallery" block and upload/select multiple images.
  • Transform this "Gallery" block into a "Tiled Gallery" block using the block toolbar transformation option.
  • Before this fix: The editor would trigger a crash/error due to missing images in the block attributes.
  • After this fix: The Tiled Gallery block should render successfully by recovering the image data from the block's innerBlocks.

@github-actions github-actions Bot added [Block] Tiled Gallery [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Jun 27, 2026
@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖



Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: July 7, 2026
    • Code freeze: July 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@Tejas-Raj01

Copy link
Copy Markdown
Contributor Author

Hi @nerrad,

I've also submitted this PR to fix an editor crash that happens when users try to transform a standard Gallery block back into a Tiled Gallery (#49606).

The crash happens because the block transformation expects the images data at the top-level attributes, but after a round-trip conversion, that data is only available inside innerBlocks. This fix safely recovers the images attribute from innerBlocks when the top-level attribute is empty or undefined, preventing the "Cannot read properties of undefined (reading 'filter')" crash.

When you have a moment, could you please take a look at this one as well and approve the CI workflows if they need maintainer clearance?

If any changes or further adjustments are needed for this block component, just let me know here and I'll push them right away. Thanks!

@Tejas-Raj01

Copy link
Copy Markdown
Contributor Author

Hi @davemac, just following up here since it's been a few days — this PR fixes the original round-trip crash you reported. CI workflows are still awaiting maintainer approval. Whenever you get a chance, could you approve the workflows or loop in someone who can review? Happy to make any changes if needed. Thanks!

@davemac

davemac commented Jul 1, 2026

Copy link
Copy Markdown

Hi @Tejas-Raj01 I'm just the reporter on this one, not a Jetpack maintainer, so I'm afraid I can't approve CI workflows or assign reviewers. That'll need to come from the Automattic side; the OSS Citizen label suggests it's in their community-PR queue.

What I can offer: I've been running the identical fix logic (default images to an array, recover from the core/image inner blocks) as a temporary theme-side patch on the affected site since reporting this, verified against the original repro. The round-trip crash is gone and images survive the transform instead of being dropped. So consider this an informal confirmation from the original reporter that the approach in this PR resolves #49606.

@jeherve

jeherve commented Jul 3, 2026

Copy link
Copy Markdown
Member

Nice fix, and recovering the images from the v2 gallery innerBlocks is exactly the right call :)

One thing I noticed while reading through it: when we rebuild the images, we're reading attributes.link, but core/image doesn't actually have a link attribute. The link destination lives in href (with linkDestination / linkTarget alongside it). So as written, link always comes back undefined, and any links set on the gallery images get dropped in the transform.

It's not a regression, since before this fix the whole thing crashed, so this is strictly better either way. But it's a one-word change, so it might be worth switching to link: attributes.href so we recover the links too.

Small nit while I'm here: this innerBlocks extraction is nearly identical to the one in the Slideshow fix (#50035). Could be nice to pull it into a shared helper down the line so the two don't drift, but I wouldn't block on it.

What do you think?

@jeherve jeherve added Bug When a feature is broken and / or not performing as intended [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 3, 2026
@Tejas-Raj01

Copy link
Copy Markdown
Contributor Author

Hi @jeherve,

Thank you for the review and the kind words! Great catch on the href attribute. I completely missed that the core/image block stores the destination there instead of link. I have updated the extraction logic to use attributes.href so the links are successfully recovered during the transform.

Regarding the shared helper for the innerBlocks extraction—I agree that would be much cleaner since the Slideshow block uses the exact same approach. I can create a follow-up PR to extract this into a shared utility function once these initial fixes land, or I can update both PRs now if you'd prefer. Just let me know!

I've pushed the fix to this branch. Thanks again!

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 3, 2026
@jeherve jeherve self-assigned this Jul 3, 2026
@jeherve jeherve merged commit 175a283 into Automattic:trunk Jul 3, 2026
72 checks passed
@github-actions github-actions Bot added this to the jetpack/16.0 milestone Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Tiled Gallery Bug When a feature is broken and / or not performing as intended OSS Citizen This Pull Request was opened by an Open Source contributor. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Ready to Merge Go ahead, you can push that green button!

Projects

None yet

3 participants